layui.define(['form', 'laydate', 'table'], function (exports) {
    var form = layui.form;
    var laydate = layui.laydate;
    var table = layui.table;
    var fiFinItemCheckDetail2Table = null;
    var view = {
        init: function () {
            this.initTable();
            this.initSearchForm();
            this.initToolBar();
            window.dataReload = function () {
                Lib.doSearchForm($("#searchForm"), fiFinItemCheckDetail2Table)
            }
        },
        initTable: function () {
            fiFinItemCheckDetail2Table = table.render({
                elem: '#fiFinItemCheckDetail2Table',
                height: Lib.getTableHeight(1),
                cellMinWidth: 100,
                method: 'post',
                url: Common.ctxPath + '/admin/fiFinItemCheckDetail2/list.json' // 数据接口
                , toolbar: true
                , title: '机构汇总清单'
                , totalRow: true
                , page: Lib.tablePage // 开启分页
                , limit: 10,
                cols: [[ // 表头
                    {

                        field: 'manageCom', //数据字典类型为 managecom_type
                        title: '管理机构编码',
                        sort: true
                    },
                    {

                        field: 'manageComText', //数据字典类型为 managecom_type
                        title: '管理机构名称',
                        sort: true
                    },
                    {

                        field: 'buTypeText', //数据字典类型为 bu_type
                        title: '业务类型',
                        sort: true
                    },
                    {

                        field: 'accountCode',
                        title: '记账科目',
                        sort: true
                    },
                    {

                        field: 'accountcodename',
                        title: '科目名称',
                        sort: true
                    },
                    {

                        field: 'finItemType',
                        title: '借贷方向',
                        sort: true
                    },
                    {

                        field: 'fmoney',
                        title: '财务金额',
                        sort: true
                    },
                    {

                        field: 'cactuMoney',
                        title: '业务金额',
                        sort: true
                    },
                    {

                        field: 'difMoney',
                        title: '金额差异',
                        sort: true
                    }


                ]]

            });

            table.on('checkbox(fiFinItemCheckDetail2Table)', function (obj) {
                var fiFinItemCheckDetail2 = obj.data;
                if (obj.checked) {
                    //按钮逻辑Lib.buttonEnable()
                } else {

                }
            })
        },

        initSearchForm: function () {
            Lib.initSearchForm($("#searchForm"), fiFinItemCheckDetail2Table, form);
        },
        initToolBar: function () {
            toolbar = {
                add: function () { // 获取选中数据
                    var url = "/admin/fiFinItemCheckDetail2/add.do";
                    Common.openDlg(url, "FiFinItemCheckDetail2管理>新增");
                },
                edit: function () { // 获取选中数目
                    var data = Common.getOneFromTable(table, "fiFinItemCheckDetail2Table");
                    if (data == null) {
                        return;
                    }
                    var url = "/admin/fiFinItemCheckDetail2/edit.do?id=" + data.id;
                    Common.openDlg(url, "FiFinItemCheckDetail2管理>" + data.id + ">编辑");
                },
                del: function () {
                    layui.use(['del'], function () {
                        var delView = layui.del
                        delView.delBatch();
                    });
                }
                ,
                exportDocument: function () {
                    layui.use(['fiFinItemCheckDetail2Api'], function () {
                        var fiFinItemCheckDetail2Api = layui.fiFinItemCheckDetail2Api
                        Common.openConfirm("确认要导出这些FiFinItemCheckDetail2数据?", function () {
                            fiFinItemCheckDetail2Api.exportExcel($("#searchForm"), function (fileId) {
                                Lib.download(fileId);
                            })
                        })
                    });
                },
                importDocument: function () {
                    var uploadUrl = Common.ctxPath + "/admin/fiFinItemCheckDetail2/excel/import.do";
                    //模板,
                    var templatePath = "/admin/fiFinItemCheckDetail2/fiFinItemCheckDetail2_upload_template.xls";
                    //公共的简单上传文件处理
                    var url = "/core/file/simpleUpload.do?uploadUrl=" + uploadUrl + "&templatePath=" + templatePath;
                    Common.openDlg(url, "FiFinItemCheckDetail2管理>上传");
                }
            };
            $('.ext-toolbar').on('click', function () {
                var type = $(this).data('type');
                toolbar[type] ? toolbar[type].call(this) : '';
            });
        }
    }
    exports('index', view);

});